<template>
	<div class="headerbox">
		<div class="top" :style="{width:(screenWidth>=1400?'1400px':'1200px')}">
			<span class="logo" @click="$router.push('/index')"><img src="../../assets/image/newimage/logo.png"><i>单校版</i></span>
			<div>
				<ul>
					 <!-- @click="gnNav1" -->
					<li><router-link to="/index" active-class="hover">考试管理</router-link></li>
					<li>答题卡制作</li>
				</ul>
				<span v-if="isLogin=={}" @click="login">登录</span>
				<p v-else>
					{{isLogin.username}}
					<b @click="quite">退出</b>
				</p>
			</div>
		</div>
		<div class="toast" v-if="isToast">
			<p v-html="toastText"></p>
			<span>2s关闭</span>
		</div>
	</div>
</template>

<script>
	import {encrypt,decrypt} from '../../utils/cryptojs'
	// import {loginQuestion} from '../../request/api.js'
	export default{
		data(){
			return{
				isLogin:{},
				screenWidth:'',
				toastText:'',
				isToast:false,
				urllink:''
			}
		},
		mounted() {
			let  userinfo=localStorage.getItem('accessToken')
			const decryptData = decrypt(userinfo)
			this.isLogin = JSON.parse(decryptData)
			this.screenWidth = document.body.clientWidth
		},
		methods:{
			login(){
				// this.$router.push('/login')
				window.location.href = this.$loginUrl + '?type=133'
			},
			// 退出
			quite(){
				// loginQuestion().then(res=>{
				// 	this.$router.push('/login')
				// 	localStorage.removeItem('accessToken')
				// })
			},
			toastHide(data){
				this.isToast=data
			}
		}
	}
</script>

<style scoped>
	.logo{
		display: flex;
		align-items: center;
		justify-content: center;
	}
	.logo img{
		width:175px;
		height:42px;
	}
	.logo i{
		display:block;
		width: 75px;
		height: 29px;
		background-color: rgba(184, 217, 253, 0.27);
		color: rgba(16, 16, 16, 1);
		font-size: 14px;
		text-align: center;
		line-height:29px;
		font-style:normal;
		margin-left:15px;
	}
	.headerbox{
		height:80px;
		background:#fff;
		width:100%;
		box-shadow: 0px 2px 6px 0px rgba(0,0,0,0.11);
	}
	.top{
		box-sizing: border-box;
		width:1400px;
		margin:0 auto;
		height:80px;
		display: flex;
		justify-content:space-between;
		line-height:80px;
		font-size:20px;
		color:#101010;
	}
	.top div{
		display: flex;
	}
	.top div ul{
		margin-right:100px;
		font-size:18px;
		display: flex;
		
	}
	.top div ul li{
		margin:0 25px;
		padding:0 10px;
		cursor: pointer;
	}
	.top div ul li a{
		display: block;
		position:relative;
		color:#101010;
	}
	.top div ul li a:hover:after,.top div ul li a.hover:after{
		content: '';
		width:100%;
		height:2px;
		background:#101010;
		border-radius:10px;
		position:absolute;
		left:0;
		bottom:20px;
	}
	.top div p{
		display: flex;
		align-items: center;
	}
	.top div p b{
		display: block;
		border:solid 1px #5677FB;
		font-size:14px;
		padding:0 15px;
		margin-left:20px;
		height:30px;
		line-height:30px;
		cursor: pointer;
	}
	.top div span{
		cursor: pointer;
	}
	.toast{
		position:fixed;
		padding:10px 30px 15px;
		box-shadow: 1px 1px 4px rgba(0,0,0,0.4);
		border-radius: 5px;
		font-size:0.9rem;
		background:#fff;
		color:#fff;
		left:50%;
		top:50%;
		transform: translate(-50%,-50%);
		z-index:1000;
	}
	.toast p{
		color:#000;
		font-size:16px;
	}
	.toast p i{
		display: block;
		color:seagreen;
		text-align: center;
		font-size:60px;
		margin-bottom:10px;
	}
	.toast span{
		display: block;
		font-size:12px;
		color:#999;
		text-align: center;
		padding-top:5px;
	}
</style>
